package lc.数组;

import java.util.Arrays;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/17
 */
public class Math5885_使每位学生都有座位的最少移动次数 {

    public int minMovesToSeat(int[] seats, int[] students) {

        Arrays.sort(seats);
        Arrays.sort(students);

        int num = 0;
        for (int i = 0; i < students.length; i++) {
            if (students[i] != seats[i]) {
                num += (Math.abs(students[i] - seats[i]));
            }

        }
        return num;
    }
}
